#ifndef SessionManager_H
#define SessionManager_H

#include <vector>
#include <map>
#include <algorithm>

#include <wx/tokenzr.h>
#include <wx/fileconf.h>
#include <wx/thread.h>

class MsnMessenger;
class MsnSession;

class SessionConnection;

class SessionManager
{
typedef std::vector<MsnSession*> SessionList;

private:
	MsnMessenger* messenger;
	SessionList sessionList;
	wxMutex sessionListMutex;

public:
	SessionManager(MsnMessenger* mm):messenger(mm){}
	~SessionManager(){}

	SessionList& GetSessionList(){return sessionList;}

	MsnSession* OpenSession(const wxString& passport);
	MsnSession* OpenSession(int transactionID, SessionConnection* conn);
	MsnSession* OpenSession(const wxString& passport, SessionConnection* conn);

	void CloseSession(MsnSession* session);
		
	MsnSession* FindSessionByPassport(const wxString& passport);
	MsnSession* FindSessionByTransaction(int transactionID);
	MsnSession* FindSessionByConnection(SessionConnection* conn);

	void Clear();
};


#endif
